<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:72:"E:\workplace\project\Sunwm\web/../application/admin\view\seller\map.html";i:1511406875;}*/ ?>
﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>选取坐标</title>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script type="text/javascript"
            src="http://webapi.amap.com/maps?v=1.4.1&key=897c37791dedfb7693f32913be501911&plugin=AMap.Autocomplete"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>
<body>
<div id="container"></div>
<div id="myPageTop">
    <table>
        <tr>
            <td>
                <label>按关键字搜索：</label>
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" placeholder="请输入关键字进行搜索" id="tipinput">
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
	if(parent.$("#lng").val() && parent.$("#lat").val()){
		var marker,map = new AMap.Map("container", {
			zoom: 16,
			resizeEnable: true,
			center: [parent.$("#lng").val(), parent.$("#lat").val()]
		});
		marker = new AMap.Marker({
			icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
			position: [parent.$("#lng").val(), parent.$("#lat").val()]
		});
		marker.setMap(map);
	}else{
		var marker,map = new AMap.Map("container", {
			zoom: 16,
			resizeEnable: true
		});
	}
    //为地图注册click事件获取鼠标点击出的经纬度坐标
    var clickEventListener = map.on('click', function(e) {
        //document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat()
		parent.$("#lng").val(e.lnglat.getLng());
		parent.$("#lat").val(e.lnglat.getLat());
		if (marker) {
            marker.setMap(null);
            marker = null;
        }
		marker = new AMap.Marker({
            icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
            position: [e.lnglat.getLng(), e.lnglat.getLat()]
        });
        marker.setMap(map);
    });
    var auto = new AMap.Autocomplete({
        input: "tipinput"
    });
    AMap.event.addListener(auto, "select", select);//注册监听，当选中某条记录时会触发
    function select(e) {
        if (e.poi && e.poi.location) {
            map.setZoom(15);
            map.setCenter(e.poi.location);
        }
    }
</script>
</body>
</html>